<?php
//容许跨域
header("Content-type:text/html;charset:utf-8");
header("Access-Control-Allow-Origin:*");
if(!empty($_POST)&&$_POST["uphone"]!=""&&$_POST["upassword"]!=""&&$_POST["uemail"]!=""){
    $phone=$_POST["uphone"];
    $password=$_POST["upassword"];
    $email=$_POST["uemail"];

    //创建链接对象
    $conn=new mysqli("127.0.0.1","root","","egg");

    //设置连接字符集
    mysqli_query($conn,"set names utf8");

    //判断是否连接成功
    // print_r($conn->connect_error);

    //编写sql指令
    $sql="INSERT INTO zhuce(uphone,upassword,uemail)VALUES('".$phone."','".$password."','".$email."')";
    //执行sql指令，并且返回结果
    $result=$conn->query($sql);

    //获取结果

    if($result){
        $arr=array("status"=>1,"msg"=>"注册成功");
        print_r(json_encode($arr));
    }else{
        $arr=array("status"=>0,"msg"=>"该电话号码已注册");
        print_r(json_encode($arr));
    }

}else{
    $arr=array("status"=>0,"msg"=>"注册失败");
    print_r(json_encode($arr));
}

?>